package com.njtoyo.taxi.admin.rest.wrapper.business.customer;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.njtoyo.taxi.admin.library.common.Enum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;

@Data
@ApiModel(value = "欠款乘客导出 wrapper")
public class CustomerArrearsExportWrapper {

    @ApiModelProperty(value = "类型，默认为all")
    @NotNull(message = "类型 不能为空")
    private Enum.CustomerArrearsCategory category = Enum.CustomerArrearsCategory.all;

    @ApiModelProperty("开始时间，精确到天，格式：yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date startDate;

    @ApiModelProperty("结束时间，精确到天，格式：yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date endDate;

    private List<Long> customerRegionIds;

    private List<Long> areaIds;

    public void setStartDate(Date startDate) {
        if (ObjectUtil.isNotEmpty(startDate)) {
            this.startDate = DateUtil.beginOfDay(startDate);
        }
    }

    public void setEndDate(Date endDate) {
        if (ObjectUtil.isNotEmpty(endDate)) {
            this.endDate = DateUtil.endOfDay(endDate);
        }
    }
}
